package com.frost500.alibabasentinelannotation;

import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 *
 */
@Slf4j
@Service
public class TestService {

    @SentinelResource(value = "doSomeThing",blockHandler = "exceptionHandler")
    public void doSomeThing(String str) {
        log.info(str);
    }

    public void exceptionHandler(String str, BlockException e) {
        log.error("blockedHandler: " + str, e);
    }

    @SentinelResource(value = "doSomeThing2",fallback = "fallBackHandler")
    public void doSomeThing2(String str) {
        log.info(str);
        throw new RuntimeException("发生异常");
    }

    public void fallBackHandler(String str) {
        log.error("fallBackHandler:"+str);
    }
}
